package com.takeoff.bluewhale.interceptor;


import org.springframework.lang.NonNull;
import org.springframework.web.servlet.HandlerInterceptor;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.takeoff.bluewhale.model.Response;
import com.takeoff.bluewhale.model.Result;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
 
public class LoginCheckInterceptor implements HandlerInterceptor {
    private ObjectMapper objectMapper;
    
    public LoginCheckInterceptor(ObjectMapper objectMapper){
        this.objectMapper=objectMapper;
    }
    @Override
    public boolean preHandle(@NonNull HttpServletRequest request,@NonNull  HttpServletResponse response,@NonNull  Object handler) throws Exception {
        // 在请求处理之前执行的逻辑
        System.out.println("Pre Handle");
//        response.setContentType("application/json;charset=UTF-8");
//		response.getWriter().write(
//				objectMapper.writeValueAsString(Response
//						.failed(Result.SIGN_ERROR)));
        return true; // 如果返回false，则停止流程，api不会被调用
    }

}